Show non-Agent run jobs as "(system)" instead of "(deleted)"

Akinori MUSHA 9 years ago
parent
commit
3b4e56d2af
2 changed files with 13 additions and 3 deletions
  1. 2 0
      app/helpers/jobs_helper.rb
  2. 11 3
      app/views/jobs/index.html.erb

+ 2 - 0
app/helpers/jobs_helper.rb

@@ -26,6 +26,8 @@ module JobsHelper
26 26
   def agent_from_job(job)
27 27
     if data = YAML.load(job.handler).try(:job_data)
28 28
       Agent.find_by_id(data['arguments'][0])
29
+    else
30
+      false
29 31
     end
30 32
   rescue ArgumentError
31 33
     # We can get to this point before all of the agents have loaded (usually,

+ 11 - 3
app/views/jobs/index.html.erb

@@ -20,11 +20,19 @@
20 20
           </tr>
21 21
 
22 22
         <% @jobs.each do |job| %>
23
-          <% agent = agent_from_job(job) %>
24 23
           <tr>
25 24
             <td><%= status(job) %></td>
26
-            <td><%= agent ? link_to(agent.name, agent_path(agent)) : "(deleted)" %></td>
27
-            <td title='<%= job.created_at %>'><%= time_ago_in_words job.created_at %> ago <%= agent ? "for #{agent.user.username}" : '' %></td>
25
+            <td><% case agent = agent_from_job(job)
26
+                   when Agent
27
+                   %><%= link_to(agent.name, agent_path(agent)) %><%
28
+                   when false
29
+                   %>(system)<%
30
+                   when nil
31
+                   %>(deleted)<%
32
+                   else
33
+                   %>(unknown)<%
34
+                   end %></td>
35
+            <td title='<%= job.created_at %>'><%= time_ago_in_words job.created_at %> ago<% if user = agent.try(:user) %> for <%= user.username %><% end %></td>
28 36
             <td title='<%= job.run_at %>'>
29 37
               <% if !job.failed_at %>
30 38
                 <%= relative_distance_of_time_in_words job.run_at %>